package es.uem.fragmentos;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import es.uem.fragmentos.dummy.Contenido;



/**
 * A fragment representing a single Item detail screen. This fragment is either
 * contained in a {@link ItemListActivity} in two-pane mode (on tablets) or a
 * {@link ItemDetailActivity} on handsets.
 */
public class ItemDetailFragment extends Fragment {
	
	private String TAG = "restaurantes";
	/**
	 * The fragment argument representing the item ID that this fragment
	 * represents.
	 */
	public static final String ARG_ITEM_ID = "item_id";

	/**
	 * The dummy content this fragment is presenting.
	 */
	private Contenido.Restaurante mItem;

	/**
	 * Mandatory empty constructor for the fragment manager to instantiate the
	 * fragment (e.g. upon screen orientation changes).
	 */
	public ItemDetailFragment() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if (getArguments().containsKey(ARG_ITEM_ID)) {
			// Load the dummy content specified by the fragment
			// arguments. In a real-world scenario, use a Loader
			// to load content from a content provider.
			mItem = Contenido.ITEM_MAP.get(getArguments().getString(
					ARG_ITEM_ID));
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_item_detail,
				container, false);
		
		
		
		// Mostramos el contenido del manejador
		if (mItem != null) {
			
			EditText nombre = (EditText) rootView.findViewById(R.id.eNombre);
			EditText direccion = (EditText) rootView.findViewById(R.id.eDireccion);
			RadioGroup tipo = (RadioGroup) rootView.findViewById(R.id.radioGroup);
			EditText notas = (EditText) rootView.findViewById(R.id.eNotas);
			
			
			
			nombre.setText(mItem.getsNombre());
			direccion.setText(mItem.getsDireccion());
			notas.setText(mItem.getsNotas());

			
			switch (mItem.getTipo()) {
			case Entregar:
				tipo.check(R.id.rEntregar);
				break;
			case Llevar:
				tipo.check(R.id.rLlevar);
				break;
			case Sentar:
				tipo.check(R.id.rSentar);
				break;
			}

			Log.d(TAG,
					"Poblando fila :" + mItem.getsNombre() + ", "
							+ mItem.getsDireccion() + " : " + mItem.getTipoString());
			
			
			
			
		}

		return rootView;
	}
	
	
	
}
